.data
array: .int 32,11,10,6,29,58,17,24
len=.-array
msg4: .ascii ""

.text
.global __main
__main:
        mov x0,#0
        bl  getmsg4
        mov x0,#0
        ldr x1,=msg4
        mov x2,x12
        mov x8,64
        svc #0

        mov x0,123
        mov x8,93
        svc #0

.text
.global getmsg4
.type   getmsg4,%function
getmsg4: 
        stp x0,x1,[sp,-16]!
        stp x2,x3,[sp,-16]!
        stp x4,x5,[sp,-16]!
        stp x6,x7,[sp,-16]!
        stp x8,x9,[sp,-16]!
        stp x10,x11,[sp,-16]!
	stp x15,x16,[sp,-16]!
	stp x17,x18,[sp,-16]!
	stp x19,x20,[sp,-16]!
	stp x29,x30,[sp, -16]!

	mov x10,len
	mov x15,#10
	mov x18,#32
	mov x17,#256
	mov x16,#48

	ldr x0,=array
	eor x2,x2,x2

	ldr x5,=msg4
	eor x7,x7,x7
	
	eor x8,x8,x8
	eor x21,x21,x21
	str x21,[x5,x7]

lt40:	ldr w1,[x0,x2]
	bl  del2

	cmp x19,#0
	beq lt42
	eor x6,x6,x6
	ldr x6,[x5,x7]
	cmp x8,#0
	beq lt41
	add x19,x19,x16
	mul x19,x19,x17
	add x19,x19,x6
	str x19,[x5,x7]
	mov x8,#0
	add x7,x7,#2
	eor x21,x21,x21
	str x21,[x5,x7]
	eor x19,x19,x19
	b   lt42
lt41:   add x19,x19,x16
	add x19,x19,x6
	str x19,[x5,x7]
	eor x19,x19,x19
	add x8,x8,#1

lt42:   cmp x20,#10
	beq lt43
	eor x6,x6,x6
	ldr x6,[x5,x7]
	cmp x8,#0
	beq lt422
	add x20,x20,x16
	mul x20,x20,x17
	add x20,x6,x20
	str x20,[x5,x7]
	mov x8,#0
	add x7,x7,#2
	eor x21,x21,x21
	str x21,[x5,x7]
	mov x20,#10
	b   lt43
lt422:  add x20,x20,x16
	add x20,x20,x6
	str x20,[x5,x7]
	mov x20,#10
	add x8,x8,#1

lt43:   ldr x6,[x5,x7]
	cmp x8,#0
	beq lt432
	mul x21,x18,x17
	add x6,x6,x21
	str x6,[x5,x7]
	mov x8,#0
	add x7,x7,#2
	eor x21,x21,x21
	str x21,[x5,x7]
	b   bc4
lt432:  add x6,x6,x18
	str x6,[x5,x7]
	add x8,x8,#1

bc4:    add x2,x2,#4
	cmp x2,x10
	bne lt40
	
	ldr x6,[x5,x7]
	cmp x8,#0
	beq lt44
	mul x21,x15,x17
	add x6,x6,x21
	str x6,[x5,x7]
	mov x8,#0
	add x7,x7,#2
	eor x21,x21,x21
	str x21,[x5,x7]
	b   bc4
lt44:   add x6,x6,x15
	str x6,[x5,x7]
	add x8,x8,#1
	
	mov x12,x7
	
	ldp x29,x30,[sp],16
	ldp x19,x20,[sp],16
	ldp x17,x18,[sp],16
	ldp x15,x16,[sp],16
	ldp x10,x11,[sp],16
        ldp x8,x9,[sp],16
        ldp x6,x7,[sp],16
        ldp x4,x5,[sp],16
        ldp x2,x3,[sp],16
        ldp x0,x1,[sp],16
	ret

.text
.global del2
.type   del2,%function
del2:   
        eor x19,x19,x19
        mov x22,x1
ld:     sub x22,x22,#10
        add x19,x19,#1
        cmp x22,#10
        bge ld
        mov x20,x22

        ret